Real-time content searching in social network

ABSTRACT

Indexing and retrieving real time content in a social networking system is disclosed. A user-term index includes user-term partitions, each user-term partition comprising temporal databases. As a post is received from a user, a user identifier, a post identifier, and a post is extracted. An object store communicatively coupled to a temporal database for recently received content is queried to determine whether terms in the post has already been stored. A term identifier is stored in the user-term index with the user and post identifiers. A forward index stores the post by post identifier. Responsive to a search query, the user-term index is searched by the user&#39;s connections and the terms. A real time search engine compiles the results of the user-term index query and retrieves the stored posts from the forward index. The search results may then be ranked and cached before presentation to the searching user.

RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.14/615,160, filed on Feb. 5, 2015, which is a continuation of a U.S.patent application Ser. No. 14/276,913, filed on May 13, 2014 and U.S.Pat. No. 8,983,928, issued on Mar. 17, 2015, which is a continuation ofU.S. patent application Ser. No. 13/866,095, filed on Apr. 19, 2013 andU.S. Pat. No. 8,756,239, issued on Jun. 17, 2014, which is acontinuation of U.S. patent application Ser. No. 12/704,400, filed onFeb. 11, 2010 and U.S. Pat. No. 8,527,496, issued on Sep. 3, 2013, whichare all incorporated by reference in their entirety.

BACKGROUND

The present invention relates generally to social networking systems andmore particularly to optimizing the storage architecture of real timecontent generated on a social networking system for efficient search andretrieval.

Social networking systems provide users with multiple mechanisms to postdiffering types of content, including text, links, photos, videos, andcomments on other users' posts, just to name a few. As a socialnetworking system grows to hundreds of millions of users, the amount ofcontent being stored grows exponentially. Storing the content in primarystorage (e.g., memory) yields the fastest retrieval, but primary storageis expensive. Thus, content is eventually stored in secondary storage(e.g., hard disk) which is less expensive, but results in longer accesstimes. Determining which content should be stored in primary storage toenable real time searching is difficult because some content may beaccessed frequently while others content is accessed only sporadically.

Conventional document indices for large scale (e.g., web) systemstypically ignore the user as a structural indexing attribute. A typicalinverted index stores a list of documents for a given term, where thelist of document is ordered by document identifier. The user, or moretypically the “author” of the document, is simply one of manykeys/attributes that are stored with the metadata for the document, butthe structure of the index is not organized in memory with respect tothe author. In addition, conventional indices typically capture thecreation date of when a document was generated as another attribute ofthe document. For example, a document, or content, that a user authored,or posted, a week ago is conventionally stored and retrieved in the samemanner as content posted in the last hour. Users may wish to search themost recently posted content of other users on a social networkingsystem before the content posted a week ago. However, terms may berepeated by users posting content, leading to an inefficient allocationof memory and future fragmentation of computer-readable storage media.Managing a pointer to a single object representing the commonly repeatedterms leads to wasteful overhead processing. Additionally, management ofold databases becomes complicated, leading to broken links. Thus,conventional search indices are not optimized for real time searching.

Additionally, users of social networking systems may wish to search thecontent of other users with which they are connected to on the socialnetworking system before searching content of random users of the socialnetworking system. Social networking systems also gather information onthe interactions between users to identify stronger connections betweenusers. Conventional social networking systems do not optimize indices toenable ranking of search results according to the strength ofconnections between users.

SUMMARY

A content storage and retrieval system in a social networking system isstructured to use the social graph—where users have connections to eachother and other nodes—to structure the content indices. In addition,indices are organized with respect to the real time posting of content,so that content is organized temporally as well as by user. “Content”includes anything that may be stored by a social networking system.

In one embodiment, a user-term index is used. A user-term index is anindex of content received in posts from users (or other nodes). A “post”includes all content contained or associated with a particularcommunication. In one embodiment, the user-term index includes storagepartitions, each partition including a plurality of temporal databases(shards). A database shard is a selected group of records, here selectedwith respect to a time period. Each temporal database includes an indexof content received over a certain time period, with the indexinformation arranged by user and term identifiers. The user-term indexstores terms from the posts of each user in an inverted manner. In oneembodiment, the user-term index stores for each user a posting listcontaining a list of term identifiers of terms included in one or moreposts, and for each term identifier, a list of post identifiers in whichthe term is found. An object store is a large allocation of addressablememory that stores content, such as a term in a post. A term from a postin a given time period is parsed and indexed into a correspondingtemporal database shard in the user-term index, and the term is storedin the object store and is given a term identifier. If the same termappears in a subsequent post authored by the same user and is indexed inthe same temporal database shard, the same term identifier is used inthe user-term index, and the subsequent post identifier is added to thepostings list for that particular user and term. A forward indexidentifies posts and stores a reference to the physical memory addressof where the elements, including metadata, of a post are stored in acontent store.

At query processing time, a search query comprising one or more terms isreceived from a user (“searching user”). The user's connections (e.g.other users or nodes represented in the social networking system thatare connected to the user) are identified based on the searching user'sprofile information. For each such connection, the connection's postlist in the user-term index is searched with respect to the queryterm(s) to identify posts by that connection that contain the queryterm(s). In another scenario, the user-term index is searched by thequery term(s) in the most recent temporal databases of all of theuser-term partitions to identify posts by everyone on the socialnetworking system that contain the query term(s). The search or searchresults may also be filtered, for example, to only show results relatedto a particular connection or group of connections (groups may bedefined or predefined by the user or by the social networking systemaccording to common attributes or other factors). A real time searchengine compiles the post identifiers from matching posts in theuser-term index query and uses the post identifiers to access theforward index and obtain the storage locations in the object stores forthe posts. The search of the user-term indices can be done in parallelacross several of the temporal databases. The search results may then beranked, for example, by relevance and time, and cached beforepresentation to the searching user.

BRIEF DESCRIPTION OF THE DRAWINGS

FIGS. 1A-C are examples of querying a real time search engine of asocial networking system according to one embodiment.

FIG. 2 is a high-level block diagram of the system architecture of asocial networking system according to one embodiment.

FIG. 3 is a schematic of the real time search engine and user-term andforward indices according to one embodiment.

FIG. 4 illustrates the storage partitions of the user-term indexaccording to one embodiment.

FIG. 5 illustrates portions of a user-term index database shard and thecorresponding term object store according to one embodiment.

FIG. 6 illustrates a portion of a forward index according to oneembodiment.

FIG. 7 is a flow chart describing the process of storing posts for realtime searching according to one embodiment.

FIG. 8 is a flow chart describing the process of retrieving posts inexecuting a real time search according to one embodiment.

FIG. 9 is a flow chart describing another process for retrieving postsin executing a real time search according to one embodiment.

The figures depict various embodiments of the present invention forpurposes of illustration only. One skilled in the art will readilyrecognize from the following discussion that alternative embodiments ofthe structures and methods illustrated herein may be employed withoutdeparting from the principles of the invention described herein.

DETAILED DESCRIPTION

Overview of a Social Networking System

A social networking system offers its users the ability to communicateand interact with other users of the social networking system. In use,users join the social networking system and then add connections toother users (individuals and entities) to whom they desire to beconnected. As used herein, the term “connection” refers to any otheruser to whom a user has formed a connection, association, orrelationship via the website. The term “user” refers to individuals andentities (such as businesses, products, bands, causes, associations,television shows, fictional characters, etc.) that may exist or berepresented in a social networking environment. Connections may be addedexplicitly by a user, for example, by an individual user selectinganother user to be a connection. A connection may also be established bya user for another user, such as an individual user designating aparticular entity to be similar to another entity. In this case, aconnection between the bands is established by the individual user.Connections may also be automatically created by the social networkingsystem based on common characteristics of the users (e.g., individualusers who are alumni of the same educational institution, businessentities that sell similar products, restaurants that have similar food,etc.). Users and other entities represented in a social networkingsystem may also be described as “nodes” that are connected, forming asocial graph.

Connections in social networking systems are usually in both directions,but need not be. For example, if Nair and Sam are both users andconnected to each other on the social networking system, Nair and Sam,both users, are also each other's connections. If, on the other hand,Nair wishes to connect to Sam to view Sam's posts, but Sam does not wishto form a mutual connection, a one-way connection is also possible. Theconnection between users may be a direct connection; however, someembodiments of a social networking system allow the connection to beindirect via one or more levels of connections or degrees or separation.Also, the term connection need not require that users actually beconnections in real life, (which would generally be the case when one ofthe users is a business or other entity); it simply implies a connectionin the social networking system.

In addition to interactions with other users, the social networkingsystem provides users with the ability to take actions on various typesof items supported by the website. These items may include groups ornetworks (where “networks” here refer not to physical communicationnetworks, but rather social networks of people, entities, and concepts)to which users of the social networking system may belong, events orcalendar entries in which a user might be interested, computer-basedapplications that a user may use via the social networking system,transactions that allow users to buy or sell items via the service, andinteractions with advertisements that a user may perform on or off thesocial networking system. These are just a few examples of the itemsupon which a user may act on a social networking system, and many othersare possible. A user may interact with anything that is capable of beingrepresented in the social networking environment or the Internet atlarge. A social networking system is capable of linking nodes that arenot confined to a particular social networking website. A socialnetworking website may be one part of a larger social networking systemthat enables users of the website to interact with each other as well aswith nodes on the Internet at large through an API or othercommunication channels. Though many of the embodiments/examples providedbelow are directed to a social networking system, the inventiondescribed herein is not limited to a social networking system, but caninclude other environments involving social networking systems, socialcontent, other types of websites and networks (including privatenetworks, local networks, mobile networks and devices, etc.).

User generated content on a social networking system enhances the userexperience. User generated content may include anything a user can addto the social networking system through any kind of post, such as statusupdates or other textual posts, location information, photos, videos,links, music, and the like. Content may also be added by a third-partyto a social networking system “communication channel,” such as anewsfeed or stream. Content “items” represent single pieces of contentthat are represented as objects in the social networking system. In thisway, users of a social networking system are encouraged to communicatewith each other by posting text and content items of various types ofmedia through various communication channels. Using communicationchannels, users of a social networking system increase their interactionwith each other and engage with the social networking system on a morefrequent basis.

Communication channels may comprise one or more different informationdelivery methods, such as a stream, a feed, a wall post, an emailcommunication, a private message, a comment on a post, a mobileapplication, a note, a third-party application, a text message, athird-party website, an advertising communication channel, a discussionboard, or any other communication channel that exists or is associatedwith the social networking system. Communication channels are discussedfurther in U.S. patent application Ser. No. 12/253,149, filed on Oct.16, 2008, which hereby incorporated by reference in its entirety.

Overview of Real Time Search for Posts

As a social networking system gains popularity, the number of users ofthe service increases dramatically, and consequently, the number ofposts on the social networking system increases exponentially. Theseposts may fill up a user's newsfeed stream or other communicationchannel very quickly. Users of a social networking system may wish toquery the service to view what their connections are posting in realtime. For example, if a user is attending an upcoming concert featuringSteel Pulse, the user may wish to query the posts of his connections tosee if they are also going to the Steel Pulse concert.

FIGS. 1A-C illustrate an exemplary user interface for querying a realtime search engine of a social networking system. The social networkingsystem presents a user interface 100 for a user that includes posted byother members of the social networking system. As shown in FIG. 1B, in asocial networking system, a user may enter a query 102 for a term, suchas “Obama.” Before executing a search query, the user may have anunfiltered view 104 (see FIG. 1A) of the posts 112 recently uploaded tothe social networking system. The unfiltered view 104 would be shown tothe user on a client device. Only some of the posts 112 may include theterm 108 being queried. However, before the search query 102 isexecuted, some of the older posts that include the relevant term 108 maynot be viewable to the user because newer posts that do not include therelevant term 108 are presented in the user interface before the olderposts. For example, FIG. 1A shows a screenshot of a user interface withmultiple posts presented in the user interface. However, only one postcontains the relevant term 108 “Obama.” Thus, a searching user may wishto view posts made by his connections that include the term “Obama” andinput 110 the term into the real time search engine in the userinterface.

A real time search engine receives a query 102 from a user's clientdevice for one or more terms that may appear in posts. The real timesearch engine executes the query 102 for the term 108 and aggregates theposts that contain the term 108 being queried. As illustrated in FIG.1B, the real time search engine then communicates this filtered view 106of posts to the user's client device. Thus, in the example above, aquery 102 for the term “Obama” may be executed by the real time searchengine. As a result, a filtered view 106 of posts containing the term108 “Obama” would be presented to the user through a communicationchannel such as a stream, news feed, ranked search results, etc. FIG. 1Billustrates the search results of the query 102 for “Obama” among theposts that are further filtered to only include posts made by thesearching user's connections. FIG. 1C illustrates the search results ofthe query 102 for “Obama” among all posts by everyone on the socialnetworking system. A filtered view 114 shows posts including the term108 “Obama” that were posted by everyone on the social networkingsystem. Using this real time search engine, a searching user is able toquery his or her connections as well as everyone on the socialnetworking system, in one embodiment, to view relevant posts.

FIGS. 1B-C also illustrate filtering options that are presented to theuser after the initial search results have been returned. As shown inFIG. 1B, a filtering interface 116 may be provided to filter the searchresults. In FIG. 1B, the currently selected filter is “Posts byFriends.” Thus, the filtered view 106 shows posts that were made by thesearching user's friends.

In one embodiment, users may further narrow search results using adropdown menu 118. For example, FIG. 1B shows that two connections haveposted links to external websites that contain the relevant term,“Obama.” If the searching user wanted to only see posted links fromconnections, the dropdown menu 118 may be selected to indicate theuser's preference. The filter results button 120 may be selected toperform the filtering. Note that the dropdown menu 118 and filterresults button 120 may also be used when viewing posts by everyone onthe social networking system. Other types of posts, such as statusupdates, wall posts, photos, videos, notes, third party applications,network, custom lists, etc., may also be selected in the post typedropdown menu 118.

In FIG. 1C, the filtering interface 116 indicates that the “Posts byEveryone” filter 124 has been selected. The “All Results” filter 126 mayalso be selected to view search results across various nodes in thesocial networking system, such as people, pages, groups, applications,events, and posts. Because many types of languages may be used in asocial networking system, search results may also be filtered bylanguage by using a language dropdown menu 122. Other types of filtersnot shown may apply certain ranking criteria to the search results, suchas a personalized ranking of the search results for the searching user.Moreover, the system itself may apply various algorithms to determinewhat the user might be most interested in or posts which are the mostclosely related to the user (e.g., in the social graph). However, themost relevant posts may be presented to the user by giving the user thefreedom to select certain filtering criteria.

System Architecture

FIG. 2 is a high level block diagram illustrating a system environmentsuitable for operation of a social networking system 200. The systemenvironment includes one or more user devices 210, one or more externalwebsites 212, a social networking system 200, and a network 222. Inalternative configurations, different and/or additional modules can beincluded in the system.

The user devices 210 comprise computing devices that can receive userinput and can transmit and receive data via a network 222. For example,the user devices 210 may be desktop computers, laptop computers, smartphones, cell phones, personal digital assistants (PDAs), or any otherdevice including computing functionality and data communicationcapabilities. The user devices 210 are configured to communicate vianetwork 222, which may comprise any combination of local area and/orwide area networks, using both wired and wireless communication systems.

FIG. 2 illustrates a block diagram of the social networking system 200.The social networking system 200 includes a web server 226, an ad server224, a forward index 234, a user-term index 236, a content server 238, areal time search engine 240, a user profile store 214, an entity store220, an application data store 230, a transaction store 216, a contentstore 218, an event store 228, and a group store 232. In otherembodiments, the social networking system 200 may include additional,fewer, or different modules for various applications. Conventionalcomponents such as network interfaces, security mechanisms, loadbalancers, failover servers, management and network operations consoles,and the like are not shown so as to not obscure the details of thesystem.

The social networking system 200 includes a computing system that allowsusers to communicate or otherwise interact with each other and accesscontent as described herein. The social networking system 200 stores inthe user profile store 214 user profiles that describe the users of asocial networking system, including biographic, demographic, and othertypes of descriptive information, such as work experience, educationalhistory, hobbies, interests, location, and the like.

Additionally, the user profile store 214 includes connections betweendifferent users and other nodes within and outside of the socialnetworking system, and may also allow users to specify theirrelationships with others. For example, these user connections allowsusers to generate relationships with other users that parallel theusers' real-life relationships, such as connections, co-workers,partners, and so forth. Users may select from predefined types ofrelationships, define their own relationship types as needed, or donothing at all. Regardless, the system tracks and stores all of theserelationships. Privacy settings may be implemented by the socialnetworking system to enable users to publish posts to user-specifiedconnections and/or groups of connections. These privacy settings may beconfigured by the user based upon the relationships types defined by theuser or by groups of connections selected by the user. As a result ofthese privacy settings, certain posts may be limited to specifiedconnections and/or groups of connections.

A user (or other type of node) may have a particular affinity, which maybe represented by an affinity score, for another node on a socialnetworking system. In this context, an affinity score indicates thestrength of correlation or interest between a user and another node inthe social networking system (or the Internet at large). Affinity scoresfor a user's connections are stored in the user profile object for thatuser in the user profile store 214. As indicated above, a node may be auser, entity, or any other object with which a user may engage andinteract on or through a social networking system. Methods fordetermining affinities between users of a social networking system aredescribed further in U.S. application Ser. No. 11/503,093, filed Aug.11, 2006, which is hereby incorporated by reference in its entirety.

The social networking system 200 maintains (or uses a third party tomaintain) data in a database about a number of different types ofobjects with which a user may interact on the social networking system200, including posts, entities, events, applications, groups,transactions, etc. To this end, each of the user profile store 214, thecontent store 218, the entity store 220, the event store 228, theapplication data store 230, the group store 232, and the transactionstore 216 stores a data structure in a database to manage the data foreach instance of the corresponding type of object maintained by thewebsite 200. The data structures comprise information fields that aresuitable for the corresponding type of object. For example, the eventstore 228 contains data structures that include the time and locationfor an event, whereas the user profile store 214 contains datastructures with fields suitable for describing a user's profile. When anew object of a particular type is created, the service 200 initializesa new data structure of the corresponding type, assigns a unique objectidentifier to it, and begins to add data to the object as needed. Thus,when a user makes a new post, such as providing a photograph, the socialnetworking system 200 generates a new instance of a post object in thecontent store 218, assigns a unique identifier to the post, begins topopulate the fields of the post with information provided by the user,such as who is tagged in the photo. Subsequently after the post is made,users interacting with the post, can add further information to the datastructure, such as comments and other tags created by other users.

An ad server 224 generates and delivers advertisements to user devices210. In one embodiment, an ad server 224 may access the various filterscreated by users and/or automatically created by the social networkingsystem 200. An analysis of the filters may help advertisers developbetter marketing campaigns through more selective targeting techniquesutilizing information about users' preferred filters. Targetingadvertisements are further described in a related application, U.S.application Ser. No. 12/195,321, filed Aug. 20, 2008, which is herebyincorporated by reference in its entirety.

The web server 226 links the social networking system 200 via thenetwork 222 to one or more user devices 210; the web server 226 servesweb pages, as well as other web-related content, such as Java, Flash,XML, and so forth. The web server 226 may include a mail server or othermessaging functionality for receiving and routing messages between thesocial networking system 200 and the user devices 210. The messages canbe instant messages, queued messages (e.g., email), text and SMSmessages, or any other suitable messaging technique. In anotherembodiment, the social networking system is implemented on anapplication running on a user device 210 that accesses information fromthe social networking system using APIs or other communicationmechanisms. A content server 238 serves the posts to the user when theuser logs into the social networking system 200.

The real time search engine 240 builds, maintains, and queries theforward index 234 and user-term index 236. A forward index 234 includesan index of the posts received by the social networking system 200. As apost is received by the web server 226, the forward index 234 storesinformation about the post, including the user identifier associatedwith the author and all content contained in and associated with thepost. A term may be extracted from any portion of a post in response toa search query, including information that is not visible to the user,such as metadata. Terms are identified in an index to become searchablein subsequent queries. Terms that may be indexed include any content inor associated with a post. Examples of where terms might be foundinclude text, links, attachments, URLs, keywords stored as metadata, IPaddresses, user ID, a nickname associated with the user, or otherinformation the system has or can predict about or relate to the postinguser or the subject matter of the post.

Types of posts include status updates, links to external websites, usergenerated videos and photos, and the like. Terms may be found, forexample, in text entered by a user, previewed text from a website thatis linked, a caption of a photo posted, a posted URL, the title orcontent of an article posted, etc. These posts are indexed in theforward index 234 and user-term index 236. Applications in a socialnetworking system 200 may access the forward index 234 to retrieve apost from the content store 218 based on the post identifier assigned toit by the forward index.

The system may also associate terms that are synonymous or closelyrelated to a term extracted from a post. For example, a post that reads“Go Niners” will index the term “Niners,” but may also index“Forty-Niners,” “9ers,” “49ers,” etc. In some embodiments the system mayalso index related words, such as “football,” “San Francisco,”“Candlestick,” etc. The system may also use voice, video or imagerecognition technology to extract or create terms relevant to contentcontained in a post. Additionally, the system employs tokenization,normalization, and expansion of terms extracted from a post.Tokenization refers to the process of stripping and splitting terms onpunctuation and normalizing words with accents, acronyms, andpossessives (e.g., “jon's” becomes “jon” & “jons”). Normalization refersto truncating words to their base (e.g., “running” becomes “run”), whileexpansion includes expanding a term to include additional forms (e.g.,“run” becomes “running,” “runs,” & “runner”).

A user-term index 236 is an inverted index organized by user identifiersand then by term identifiers of terms appearing in the posts made byeach user. In building the user-term index 236, several storagepartitions may be used. Each user of the social network service 200 ishash mapped to one of the storage partitions, based on the useridentifier. When a user to the social networking system 200, theuser-term index 236 references the terms contained in the post in theparticular storage partition for the user. For each term, a posting listof the post identifiers of that user's posts in which the term appearsis stored in the user-term index 236. FIG. 5 illustrates in more detailone embodiment of the user-term index 236.

A user wishing to query posts made to the social networking system forcertain terms, such as “Obama” in the example above, may execute thequery through the web server 226. The real time search engine 240receives the user's query of terms and performs the query by queryingthe user-term index 236 with the user identifier of the searching userand the terms of the query. Terms may be entered manually, and a usermay choose between terms adaptively suggested by the system in responseto the inputted text. Other methods of inputting terms may also be used,such as the selection of terms recently searched by other users in thesocial networking system. The user-term index 236 compiles the postidentifiers of those posts by the user's connections that include theterms in the user's query. The real time search engine 240 receives theresults of the search from the user-term index 236 and retrievesrelevant posts from the forward index 234 for presentation to the user.

Real Time Search Engine

FIG. 3 illustrates the interaction of the modules of the real timesearch engine 240 interacting with the user-term index 236, forwardindex 234 and global cache 308. A global cache 308 may contain thesearch results for the most recent queries, search results for the mostpopular searches, a combination of the foregoing, or other usefulresults. In one embodiment, a real time search engine 240 does not havea global cache 308.

An indexing module 302 receives posts and extracts information from theposts 112, including the author's user identifier and the terms of thepost. The indexing module 302 stores the post terms in the user-termindex 236 as described above, and stores the user identifier, the postidentifier, and other useful metadata in the forward index 234. Suchuseful metadata may include, for example, the number of terms in thepost, the author of the post, the date and time of the post, positionalinformation of the terms, and the like.

An aggregator 304 receives a query 102 from a user of the socialnetworking system 200. The aggregator 304 extracts the searching user'suser identifier, and then uses that identifier to determine a list ofthe searching user's connections in the social networking system 200.Using the query 102 and the connections list, the aggregator 304 gathersposts from the most recent shards of the user-term index 236 thatsatisfy the query 102. The aggregator 304 hashes the user identifier ofeach connection to determine which partition holds the database shardsassociated with that connection. The aggregator 304 then assembles theposts that contain the term posted by that connection to be presented tothe user. A user may also perform searches that are not limited in scopeto the searching user's connections, such as a search on posts of allusers of the social networking system and a search of all nodesconnected to the social networking system. Moreover, the system can alsoprovide an interface to limit search results to those posts made withina specified period of time (e.g. recent posts, posts within the lastweek, posts within the last year, posts made at any time, etc.). Thesearching user may limit the scope of the search at the outset, or mayfilter the results after a search is performed using this interface.

As an example, a query for “Obama” is performed by Suzie. Suzie has twoconnections in the social network 200, Jeannie and Oliver. Theaggregator 304 gathers posts by Jeannie and Oliver that contain the term“Obama” in the most recent shards of the user-term index 236. In oneembodiment, the aggregator 304 gathers the posts from the most recentshards of the user-term index 236 satisfying the search query 102 forall users on the social networking system 200. The aggregator 304 mayalso query older databases in the user-term index 236 depending onwhether enough posts have been retrieved. In one embodiment, the searchresults are updated in real time as newer posts are uploaded to thesocial networking system.

The real time search engine 240 also includes a ranking module 306. Aranking module 306 may comprise various ranking criteria used to rankthe search results. For example, the ranking module 306 may compriseranking criteria such as reputation, interaction by population (i.e.,“popularity” ranking), and similarity measures between content/contentauthor and the searching user (i.e., location, age, gender, etc.).Determining what information is relevant may differ from user to user.Various methods of determining what might interest a particular user maybe implemented to rank search results. Moreover, in one embodiment, ifno search results are found for a user's connections, the system willprovide search results from other users of the social networking system.In other embodiments, search results may also include results fromoutside the social networking system, such as from third party websites.Search results may also contain advertisements or other paid or non-paidcommercial content. Further information about ranking the search resultsis described below.

Index Architecture

As illustrated in FIG. 4, the user-term index 236 is comprised of aplurality of user-term partitions 400 (i.e., user-term partitions 1through n). A partition is a logical or physical allocation of storageon a computer-readable storage medium. In one embodiment, the number ofuser-term partitions 400 implemented is a prime number to achieve aneven distribution of users across the user-term partitions 400. Theusers of a social networking system 200 are assigned to specificuser-term partitions using a hash function.

For example, a user identifier may be hashed into one of thirteenpartitions by taking the modulo of the user identifier by the number ofpartitions (e.g., 170 mod 13). The modulo operation is the remainder ofa division operation. So, the operation “170 mod 13” would result in “1”because the remainder of 170 divided by 13 is 1. Any number ofpartitions may be used. Within each user-term partitions 400 there are aplurality of temporal database shards 402, each of which holds atime-specific portion of the user-term index (i.e., user-term indices 1through n, corresponding to shards 402 a to 402 n). The temporaldatabase shards 402 are organized by time such that the posts indexed indatabase shard i+1 in their corresponding partitions 400 were postedmost recently in time than posts in database shard i. A new post beingstored in the forward index 234 is also indexed in the user-term index236 in the most recent database shard 402 n, depending on the useridentifier 124 for the post. Any number of databases 402 may be used ineach user-term partition 400. In one embodiment, thirty (30) databasesshards 402 are used for each of the user-term partition 400, onedatabase shard for each day of a month. In other embodiments, twelve(12) database shards are used, one shard for each hour. In oneembodiment, the number of temporal databases used may fluctuate overtime.

When indexing a post, the terms in the post are parsed and stored in theuser-term partition 400 for the author's user identifier. As new postsare received, extracted information, such as the author's useridentifier, the parsed post's term identifiers, and post identifiers,are stored in the most recent shards 402 n, until these shards arefilled to capacity. At some point, a new empty shard is created, and theoldest shard (e.g., shard 402 a) in the storage partition is deleted.For example, if it is determined that the most recent shard 402 n is atfull capacity, a new shard is created and the oldest shard 402 a isdeleted. In this way, the most recent posts may be quickly stored to adatabase in memory.

As the user-term index 236 fills in capacity, the indexing module 302determines whether a new shard for a particular user-term partition 400should be created. The decision to create a new shard is a design choicedependent on the physical storage capacity of the computer-readablestorage medium, among other factors. If a new shard is created, then thenew shard 402(n+1) becomes the most recent shard. If a new shard is notcreated, then the most recent shard remains the same. The decision tocreate a new shard is a separate process that monitors the size of theshard and creates a new one as needed.

Also illustrated in FIG. 4 in each user-term partition 400 are objectstores 404 a-n. An associated object store is communicatively coupled toeach of the database shards 402. An object store is a large allocationof memory that is addressable. By having an object store associated witheach database shard 402, management of the term identifiers for termsstored in the database shard is simplified. Therefore, when the oldestshard is deleted to make room for a new shard, the object storeassociated with the oldest shard is deleted as well and a new objectstore is associated with the new shard.

Each of the object stores 404 a-n includes the terms used in the postsindexed in the user-term indices 402 a-n. When a new post is indexed inthe most recent database shard 402 n, the hashes of the terms in thepost are searched in the object store corresponding to the most recentdatabase shard 402 n. If the hash of a term is not found in the objectstore, it is added to the object store. If the hash of a term is foundin the object store, then term identifier is indexed in the databaseshard 402 n. In this way, the database shards 402 are organized by userand by term. Metadata about the new post, including its post identifieras assigned by the forward index 234, is also stored in the most recentdatabase shard 402 n.

For example, a post, such as a status update, may include the text “islistening to John Mayer right now.” This post would have five (5)indexable terms (because the terms “is” and “to” would not be indexed)that would each be hashed into the corresponding object store for theuser-term partition and indexed in the most recent database shard 402 n.If the terms were found in the object store corresponding to the mostrecent shard, then the corresponding term identifiers for the termswould be stored with the metadata for the post. In this case, themetadata includes the user identifier for the user who posted the statusupdate and the post identifier that identifies the status update post inthe forward index 234. If terms were not found in the object storecorresponding to the most recent shard, then those terms would be storedin the object store and corresponding term identifiers would be storedwith the metadata in the most recent database shard 402 n. Although thisexample uses a status update post, other types of posts may be similarlyindexed such that each term in or associated with the post is indexedinto the user-term index 236.

In one embodiment, when the real time search engine receives a queryfrom a searching user, the user-term partitions corresponding to useridentifiers for the searching users' connections must first beidentified. Returning to the example above, a query from Suzie for“Obama” is received by the real time search engine. The aggregator 304gathers posts from the user-term index 236, by hashing user identifiersfor Suzie's connections to identify the user-term partitions that areassociated with Suzie's connections, Jeannie and Oliver. The query for“Obama” would be performed on the most recent database shard 402 n thatcorresponds to Suzie's connections, Jeannie and Oliver. Thus, the term“Obama” is searched by its hash in the most recent database shard in theuser-term partition for Jeannie and also searched in the most recentdatabase shard in the user-term partition for Oliver. The hash of“Obama” corresponds to the term identifier for “Obama.” The searchresults, including the post identifiers for posts that contain theterms, are compiled by the aggregator 304 so that the posts may beassembled. Using the post identifiers as a lookup, the store locationsof the posts in the object store are found in the forward index 234. Theaggregator 304 then retrieves the posts containing the terms from theobject store. In one embodiment, the global cache 308 stores the searchresults.

FIG. 5 illustrates portions of a user-term index database shard and anobject store corresponding to the shard in one embodiment. The user-termindex 500 includes records 508, 510, 512, and 514 of data. The firstcolumn 502 of data represents the user identifier of the author whocomposed the post. The second column 504 of data represents the termidentifier, or hash, of a term found in the post. The third column 506of data represents the post identifiers in which the term is found. Forexample, in the first record 508 of the user-term index 500, a user withan identifier of “1” uploaded a post with a term identifier of“057901e7” in the posts identified by the identifiers “29,” “25,” and“13.”

FIG. 5 also illustrates a portion of the object store 528 associatedwith the portion of the user-term index 500 in one embodiment. Theobject store 528 includes records 520, 522, and 524 of data. The firstcolumn 516 of data represents the term identifiers of the terms and theactual location in memory where the term is stored. The second column518 of data represents the hashed term. For illustration purposes, athird column 526 shows an actual text string that is stored in memory.For example, in the first record 520 of the object store 516, the termidentifier “057901e7” represents the term “Jamie,” hashed as “057901e7.”In other embodiments, a physical address in memory is referenced in theobject store. As an example, the object store portion 528 shows theaddress of term identifier “057901e7” as “0123abcd.”

The object store is a large allocation of memory that is addressable.Instead of randomly allocating memory, which might lead tofragmentation, the object store allocates storage serially. The objectstore allocates arrays, so the data string “Slater” can be allocated 6bytes. Then the physical address in memory where “Slater” is stored ispassed as a reference. The reference only occupies 4 bytes. Thus, the 6byte string is converted to a 4 byte reference. The next term to bestored, such as “Irons,” is allocated the next 5 bytes. Similarly, useridentifiers are stored using an object store (user profile store) topass 4 byte references, and post identifiers are also stored in anobject store (content store) to pass 4 byte references. Otherinformation may be stored in object stores, such as metadata and forwardindex data blobs, to assign a unique identifier for each piece ofinformation.

As part of a post, term metadata, such as where the term is positionedin the post, the time and date of when the post was made, the post type(i.e., photo, video, status message, etc.), locale of the user,geographic location at the time of the post, etc., can fit into an arraythat only occupies 4 bytes most of the time. If there are multiplepieces of term metadata, then a list of metadata can be created and a 4byte reference to the list can be appended to the post identifier. Thus,the post identifier reference and the term metadata can be passed as areference that occupies 8 bytes. This type of reference passing isuseful because servers utilize a 64-bit architecture (8 bytes), but only32 bits (4 bytes) are needed for the post identifier, the useridentifier, and the term identifier. Thus, retrieval of the post and howit was presented, i.e., the post identifier and the term metadata thatfits in 8 bytes, can be executed very quickly because the data is storein inline memory. In contrast, conventional methods of storing a termemploy a pointer to a physical address in memory. Pointer management,which wastes processing resources, is thus avoided by utilizing theobject store.

FIG. 6 illustrates a portion of the forward index in one embodiment. Theforward index 600 includes records 608, 610, 612, 614, and 616 of data.The first column 602 of data represents the post identifiers of postsmade to the social networking system 200. The second column 604 of datarepresents the user identifiers of the users who authored the posts. Theforward index 600 is indexed based on the first column 602 of data thatrepresents the post identifiers and is not indexed based on the useridentifiers in the second column 604 of data. The third column 618 ofdata represents the physical address in memory where the data is stored.The fourth column 606 of data represents the post stored in memory. Thethird column 618 may comprise the physical addresses in memory where theposts are stored. For example, the first record 608 of the forward index600 has a post identifier “78” for a post that was authored by the useridentifier “Joe” in which the post reads “Taj wins the pipeline masters,not Jamie or Slater.” The full text of the post may not be stored in theforward index 600, but the full text is illustrated in FIG. 6 in thefourth column 606 for purposes of illustration. The forward index 600also stores metadata about the post (not illustrated in FIG. 6),including enough information about the post to recreate it with the datathat is commonly available in local memory, such as cache memory, aswell as other metadata used for filtering, such as locale, geographiclocation, post type (photo, note, status update, etc.). Similarly, thesecond column 604 of data representing the user identifiers of the userwho authored the posts is depicted in FIG. 6 for illustration purposesonly and may not be stored as part of the forward index 600, but ratheras part of the post itself.

Thus, both the user-term index 236 and the forward index 234 areutilized in the storage and retrieval of terms for real time contentsearching. FIGS. 5 and 6 will be referenced as examples in theflowcharts of FIGS. 7 and 8.

Indexing and Retrieving Methods

FIG. 7 further illustrates the process of indexing content for real timesearching according to one embodiment. As a post is made to the socialnetworking system, the authoring user's identifier is hashed todetermine 700 which user-term partition, storing a group of shards, ortemporal databases as described above, is associated with the authoringuser. For example, suppose Suzie posts a link to an external websitewith the post “Going to watch Jamie O'Brien surf pipe” Suzie's useridentifier, “1” in FIGS. 5 and 6, would be hashed to determine which ofthe user-term partitions is associated with Suzie. Returning to FIG. 7,extracted metadata is received 702 for a post. In one embodiment, theextracted metadata includes user and post identifiers. The post includesat least one term. The post is parsed 704 for terms. Thus, metadataabout the post in this example, including the user and post identifiersfor the post, “1” and “25” according to record 616 of the forward index600 portion illustrated in FIG. 6, would be extracted and the terms inthe post would be parsed 704.

Each term in the post would be searched, or hashed 706, the object storecorresponding to the most recent shard for a term identifier. A separateprocess determines whether a new shard should be created asynchronouslyfrom the process of indexing content for real time searching. Thisseparate process also decides when to delete or archive old shards tofree up storage resources, both in memory and on disk. Each term isstored 708 in the object store corresponding to the most recent shardresponsive to not finding a matching term identifier in the objectstore. For each of these stored 708 terms, a new term identifier iscreated. Metadata is also stored 710 for each term in the most recentshard. This unique term identifier system is related to a pendingapplication, titled “Lock-Free Concurrent Object Dictionary,” U.S. Ser.No. 12/651,296, filed on Dec. 31, 2009, and incorporated herein byreference.

FIG. 8 further illustrates an embodiment of the process of retrievingcontent in executing a real time search according to one embodiment. Asearch query is received 800 comprising terms from a user. Thecorresponding user identifier of the searching user, a list of useridentifiers for the user's connections, and the terms are sent 802 to anaggregator module 304 within the real time search engine 240. Based onthe identifiers of the user's connections, the aggregator module 304 canhash each user identifier to identify the user-term partitions thatcontain the temporal databases associated with the user's connections,as described above.

For each of the user's connections, the terms are queried, or searched804, in the shards of the corresponding groups of shards contained inthe user-term partitions that constitute the user-term index 236,starting with the most recent shards. As described above, this search804 may include a hash of the term to the corresponding object storeassociated with the most recent database shard.

The post identifiers for posts made by the user's connections that matchthe terms are compiled 806. As matches are identified in the search 804,the corresponding post identifiers for the search results may becompiled by the aggregator module. The posts that contain the matchingterms are retrieved 808 from the forward index 234 based on the compiledpost identifiers. If there are enough retrieved posts from the search ofthe most recent shard, then the search results are returned 810 to theuser. If there are not enough posts, then additional searches 804 areperformed in progressively older shards until enough posts areretrieved. The threshold for what constitutes enough posts is a designparameter that is determined by the administrators of the system.

As an example, suppose a user wanted to search his connections (whichinclude Suzie and Joe) for posts with the terms “Jamie O'Brien.” Thesearch query is received 800 and the corresponding user identifier ofthe searching user, a list of user identifiers for the user'sconnections, and the terms are sent to the aggregator module. Theaggregator module 304 would identify which of the user-term partitions400 are associated with Suzie and Joe. Suppose that both Suzie and Joeare associated with the same user-term partition and that the mostrecent database shard is illustrated as the user-term index 500 of FIG.5. Thus, the terms “Jamie” and “O'Brien” would be queried in theuser-term index 500.

The terms “Jamie” and “O'Brien” are searched 804, or hashed, in theobject store corresponding to the most recent database shard first,illustrated as the object store 528 in FIG. 5. As more posts are needed,searches may be performed in progressively older shards. Thus, the term“Jamie” is hashed as the term identifier “057901e7,” and the term“O'Brien” is hashed as the term identifier “089f0267.” Thus, these termidentifiers are searched in the user-term index 500. Records 508 and 512both include term identifier “057901e7” while record 510 includes termidentifier “089f0267.” However, the only post identifiers that are inall of the records 508, 510, and 512 are post identifiers “25” and “13.”Thus, these post identifiers are compiled 806. The posts can beretrieved 808 from the forward index 234, illustrated as the forwardindex 600. The post identifiers “25” and “13” are associated with theposts “Going to watch Jamie O'Brien surf pipe” and “watching the newJamie O'Brien movie” which were both authored by Suzie, having useridentifier “1,” as illustrated by the records 614 and 616 in FIG. 6.

Ranking and Caching Search Results

As further illustrated in FIG. 8, the search results comprising theretrieved posts are then returned 810 to the user. Presentation of thesearch results to the user may vary depending on the preferences of theuser or the system. For example, the user may not have many connectionsusing the social networking system and would like to search everyone onthe social networking system. After the search results are returned 810to the user, the user may wish to change the filter to a view of thesearch results of everyone on the social networking system. This changeof filter is a new search against the entire user-term index, searchingfor the query in the most recent database shards. This is furtherillustrated in FIG. 9 in which a query comprising terms is received 900from a user, the user identifier and terms are sent 902 to an aggregatormodule, the terms are searched 904 in the most recent shards of theuser-term index, the post identifiers corresponding to the terms arecompiled 906, the posts are retrieved 908 from the forward index, thesearch results comprising the retrieved posts are returned 910 to theuser. Similar to the process in FIG. 8, if more posts are needed, asearch is performed against progressively older shards. Depending on thequery, other users may have made relevant posts after the searching userrequested the query. An independent process may update the searchresults to enable the user to quickly view newer search results inreal-time.

Search results from the processes illustrated in FIGS. 8 and 9 may beranked by a ranking module 306. The real time search engine 240 may rankthe search results using the ranking module 306 before the searchresults are returned 810 to the user. Using various ranking criteria,the search results may be reordered to ensure the most relevantinformation is presented to the user. For example, search results may beranked by first displaying posts from direct connections, then otherusers that are indirectly connected to the searching user, then randomusers, and, in one embodiment, third party content published outside ofthe social networking system. Search results may also be stored in aglobal cache 308 so that searches for popular terms are not duplicated.

The ranking module 306 can use a variety of criteria to rank searchresults. The ranking module 306 may use the reputation of a user on thesocial networking system 200 as a basis for ranking search results. Thismeans that posts from users with low reputations, which may comprisespammers or malicious users, would appear lower in the resultspresentation than posts from users with higher reputations.

The ranking module 306 may also utilize a “popularity” ranking, or aranking by the interactions by population. Some users may be more“popular” on a social networking system 200 than other users. These morepopular users have more interactions than other users. Thus, a metricsuch as a popularity score may be used to rank the search results byusers having a higher popularity score than those with lower popularityscores.

Another basis for ranking search results includes similarity measuresbetween the post/post author and the searching user. The similarityscore may be measured based on demographic information (age, gender,location, interests, etc.) or other similarity measures based on socialgraph information. Search results may be ranked, in one embodiment, sothat post authors having similar demographic information as thesearching user appear higher in the search results than content authorshaving different demographic information.

Search results may be ranked such that posts from authors closer to thesearching user in proximity on a social graph appear higher than postsfrom authors further away from the searching user on the social graph.Proximity on the social graph may be determined using multiple factors.For example, a user may be directly connected to a set of users andindirectly connected to another set of users. Direct connections have acloser proximity to the searching user than indirect connections.

Another factor that may be used to determine proximity on the socialgraph is the affinity of the searching user for other users. As anexample, a searching user who interacts with a connection regularly onthe social networking system would have a high affinity for theconnection. Thus, search results from that connection may be rankedhigher because of the closer proximity on the social graph to thesearching user as determined by calculating a proximity score.

Yet another ranking scheme may incorporate affinity for other nodes onthe social networking system as a basis for ranking search results. Forexample, the searching user may have a particularly high affinity for anode on the social networking system representing a social online puzzlegame. In one embodiment, a ranking module 306 may receive the searchinguser's high affinity for puzzle games and return posts from other userson the social networking system that also have a high affinity forpuzzle games. In this way, the first few retrieved posts may be morerelevant to the searching user because of the shared affinity for puzzlegames. In this way, the ranking may be “personalized” for the searchinguser because the ranking incorporates the personal affinities for othernodes on the social networking system (or on the Internet in general insome embodiments).

Because of ease of interactions between users through a socialnetworking system, certain terms may be more popular at a certain pointin time, especially during major events. As a result, a global cache 308may be utilized so that duplicative searches for the same terms areavoided. For example, the death of a celebrity may spur users of thesocial networking system to post links to news articles, videos, statusupdates, and the like. Searching users may wish to query the posts ofhis or her connections on the social networking system regarding thedeath of the celebrity. Using a global cache 308, duplicative searchesmay be avoided.

Finally, the real time search engine 240 may include search results fromusers unconnected to the searching user. Different combinations ofranking may result in unconnected users making new connections becauseof shared affinities, demographics, or random search results. The realtime search engine 240 also searches all nodes connected to the socialnetworking system 200, such as entities, applications, websites, as wellas events and groups. Advertisers may also make advertisementssearchable such that relevant advertisements also appear in the searchresults.

SUMMARY

The foregoing description of the embodiments of the invention has beenpresented for the purpose of illustration; it is not intended to beexhaustive or to limit the invention to the precise forms disclosed.Persons skilled in the relevant art can appreciate that manymodifications and variations are possible in light of the abovedisclosure.

Some portions of this description describe the embodiments of theinvention in terms of algorithms and symbolic representations ofoperations on information. These algorithmic descriptions andrepresentations are commonly used by those skilled in the dataprocessing arts to convey the substance of their work effectively toothers skilled in the art. These operations, while describedfunctionally, computationally, or logically, are understood to beimplemented by computer programs or equivalent electrical circuits,microcode, or the like. Furthermore, it has also proven convenient attimes, to refer to these arrangements of operations as modules, withoutloss of generality. The described operations and their associatedmodules may be embodied in software, firmware, hardware, or anycombinations thereof.

Any of the steps, operations, or processes described herein may beperformed or implemented with one or more hardware or software modules,alone or in combination with other devices. In one embodiment, asoftware module is implemented with a computer program productcomprising a computer-readable medium containing computer program code,which can be executed by a computer processor for performing any or allof the steps, operations, or processes described.

Embodiments of the invention may also relate to an apparatus forperforming the operations herein. This apparatus may be speciallyconstructed for the required purposes, and/or it may comprise ageneral-purpose computing device selectively activated or reconfiguredby a computer program stored in the computer. Such a computer programmay be stored in a tangible computer readable storage medium or any typeof media suitable for storing electronic instructions, and coupled to acomputer system bus. Furthermore, any computing systems referred to inthe specification may include a single processor or may be architecturesemploying multiple processor designs for increased computing capability.

Finally, the language used in the specification has been principallyselected for readability and instructional purposes, and it may not havebeen selected to delineate or circumscribe the inventive subject matter.It is therefore intended that the scope of the invention be limited notby this detailed description, but rather by any claims that issue on anapplication based hereon. Accordingly, the disclosure of the embodimentsof the invention is intended to be illustrative, but not limiting, ofthe scope of the invention, which is set forth in the following claims.

What is claimed is:
 1. A computer implemented method comprising:receiving a query from a client device associated with a user, the querycomprising a term associated with a term identifier; searching, based inpart on the term identifier, a first portion of a user-term indexcomprising time-ordered database shards of records for post identifiersof posts that include the term and that are associated with connectionsof the user, where the user-term index comprises shards of records thatare searched from newest to oldest, the searching comprising: matchingthe term identifier to corresponding term identifiers in shards ofrecords within the selected portion, the selected portion including useridentifiers associated with connections of the user, and wherein thematching identifies post identifiers for posts that include the term andare associated with a connection of the user; and retrieving posts froman index using the identified post identifiers, the retrieved posts forpresentation to the user.
 2. The computer implemented method of claim 1,wherein data in the user-term index is arranged by the user identifiersand includes a plurality of user identifiers associated with a pluralityof users of a social networking system and a plurality of termidentifiers associated with a plurality of terms used by the pluralityof users.
 3. The computer implemented method of claim 1, furthercomprising: response to not reaching a threshold number of retrievedposts, searching, based in part on the term identifier, a second portionof the user-term index that comprises shards of records that are olderthan those in the first portion, and the shards of records in the secondportion of the user-term index are searched from newest to oldest. 4.The computer implemented method of claim 1, further comprising:performing a hash function on the term to generate a term identifier;querying for the term identifier in an object store associated with themost recent database shard in the selected partition of the user-termindex; and allocating memory in the object store for the term identifierresponsive to not finding the term identifier in the object store. 5.The computer implemented method of claim 1, wherein searching, based inpart on the term identifier, the first portion of the user-term indexcomprising time-ordered database shards of records for post identifiersof posts that include the term and that are associated with connectionsof the user comprises: performing a hash function to associate the useridentifier to a particular partition of the user-term index; andselecting the particular partition of the user-term index.
 6. Thecomputer implemented method of claim 4, wherein the hash function takesa modulo of the user identifier by the number of partitions.
 7. Thecomputer implemented method of claim 1, wherein the time-ordereddatabase shards of records comprises a shard for each day of the month,a shard for each month of the year, or a shard for each hour of the day.8. The computer implemented method of claim 1, further comprising:determining that all of the shards are filled to capacity; and creatinga new shard, and setting the new shard as the most recent databaseshard.
 9. The computer implemented method of claim 1, furthercomprising: deleting the oldest shard, of the time-ordered databaseshards of records; and deleting an object store associated with theoldest shard.
 10. A computer implemented method comprising: searching,based in part on a term identifier associated with a term, a firstportion of a user-term index comprising time-ordered database shards ofrecords for post identifiers of posts that include the term and that areassociated with connections of a user, where the user-term indexcomprises shards of records that are searched from newest to oldest, thesearching comprising: matching the term identifier to corresponding termidentifiers in shards of records within the selected portion, theselected portion including user identifiers associated with connectionsof the user, and wherein the matching identifies post identifiers forposts that include the term and are associated with a connection of theuser; and retrieving posts from an index using the identified postidentifiers, the retrieved posts for presentation to the user.
 11. Thecomputer implemented method of claim 10, further comprising: response tonot reaching a threshold number of retrieved posts, searching, based inpart on the term identifier, a second portion of the user-term indexthat comprises shards of records that are older than those in the firstportion, and the shards of records in the second portion of theuser-term index are searched from newest to oldest.
 12. The computerimplemented method of claim 10, further comprising: performing a hashfunction on the term to generate a term identifier; querying for theterm identifier in an object store associated with the most recentdatabase shard in the selected partition of the user-term index; andallocating memory in the object store for the term identifier responsiveto not finding the term identifier in the object store.
 13. The computerimplemented method of claim 10, wherein searching, based in part on aterm identifier associated with a term, the first portion of theuser-term index comprising time-ordered database shards of records forpost identifiers of posts that include the term and that are associatedwith connections of a user comprises: performing a hash function toassociate the user identifier to a particular partition of the user-termindex; and selecting the particular partition of the user-term index.14. The computer implemented method of claim 13, wherein the hashfunction takes a modulo of the user identifier by the number ofpartitions.
 15. The computer implemented method of claim 10, wherein thetime-ordered database shards of records comprises a shard for each dayof the month, a shard for each month of the year, or a shard for eachhour of the day.
 16. The computer implemented method of claim 10,further comprising: determining that all of the shards are filled tocapacity; and creating a new shard, and setting the new shard as themost recent database shard.
 17. The computer implemented method of claim10, further comprising: deleting the oldest shard, of the time-ordereddatabase shards of records; and deleting an object store associated withthe oldest shard.
 18. A computer program product comprising anon-transitory computer-readable storage medium having instructionsencoded thereon that, when executed by a processor, cause the processorto perform steps comprising: receiving a query from a client deviceassociated with a user, the query comprising a term associated with aterm identifier; searching, based in part on the term identifier, afirst portion of a user-term index comprising time-ordered databaseshards of records for post identifiers of posts that include the termand that are associated with connections of the user, where theuser-term index comprises shards of records that are searched fromnewest to oldest, the searching comprising: matching the term identifierto corresponding term identifiers in shards of records within theselected portion, the selected portion including user identifiersassociated with connections of the user, and wherein the matchingidentifies post identifiers for posts that include the term and areassociated with a connection of the user; and retrieving posts from anindex using the identified post identifiers, the retrieved posts forpresentation to the user.
 19. The computer program product of claim 18,wherein the instructions further cause the processor to perform thesteps comprising: performing a hash function on the term to generate theterm identifier; querying for the term identifier in an object storeassociated with the most recent database shard in the selected partitionof the user-term index; and allocating memory in the object store forthe term identifier responsive to not finding the term identifier in theobject store.
 20. The computer program product of claim 18, whereinsearching, based in part on the term identifier, the first portion ofthe user-term index comprising time-ordered database shards of recordsfor post identifiers of posts that include the term and that areassociated with connections of the user comprises: performing a hashfunction to associate the user identifier to a particular partition ofthe user-term index; and selecting the particular partition of theuser-term index.